﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using FastReflectionLib;
using XYTXL.API;
using Newtonsoft.Json;
using XYTXL.Data;
using System.Data;
using Newtonsoft.Json.Linq;
using System.Net;
using System.Configuration;
using System.IO;

using System.Xml;
using System.Threading.Tasks;
using Newtonsoft.Json.Converters;

namespace XYTXL.API
{
    public class BaseManage : IWsService
    {
        public void ProcessRequest(HttpContext context, ref Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            MethodInfo methodInfo = typeof(BaseManage).GetMethod(msg.Action.ToUpper());
            BaseManage model = new BaseManage();
            methodInfo.FastInvoke(model, new object[] { context, msg, P1, P2, UserInfo });
        }
        public void GETUSERINFO(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            msg.Result = UserInfo;
        }

        /// <summary>
        /// 添加聚会
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void ADDJH(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {

            xy_jh model = new xy_jh();
            model.jh_addr = context.Request["jhdd"] ?? "";
            model.jh_rq = DateTime.Parse(context.Request["jhsj"] ?? "");
            model.jh_num = context.Request["jhrs"] ?? "";
            model.jh_tel = context.Request["jhlxdh"] ?? "";
            model.jh_fqrxm = context.Request["lxr"] ?? "";
            model.jh_nj = context.Request["nj"] ?? "";
            model.jh_zymc = context.Request["zymc"] ?? "";
            model.jh_zydm = context.Request["zydm"] ?? "";
            model.jh_xbmc = context.Request["xbmc"] ?? "";
            model.jh_xbdm = context.Request["xbdm"] ?? "";
            model.jh_bj = context.Request["bj"] ?? "";
            model.jh_sh = "0";
            model.CRUser = UserInfo.User.UserName;
            model.CRDate = DateTime.Now;
            new xy_jhB().Insert(model);
            msg.Result = model;
        }

        /// <summary>
        /// 获取聚会列表
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void MJHLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {

            msg.Result = new xy_jhB().GetDTByCommand(" select * from xy_jh where CRUser='" + UserInfo.User.UserName + "'  order by CRDate desc ");//
            //msg.Result1 = new JH_Auth_FormBaseB().GetDTByCommand(" select distinct xbmc,xbdm from xy_xbdm  order by xbmc ");//
        }


        /// <summary>
        /// 添加活动
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void ADDHD(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {

            xy_act model = new xy_act();
            model.act_name = context.Request["actname"] ?? "";
            model.act_fqr = context.Request["actfqr"] ?? "";
            model.act_time = DateTime.Parse(context.Request["acttime"] ?? "");
            model.act_addr = context.Request["actaddr"] ?? "";
            model.act_num = context.Request["actnum"] ?? "";
            model.act_zzr = context.Request["actzzr"] ?? "";
            model.act_tel = context.Request["acttel"] ?? "";
            model.CRDate = DateTime.Now;
            model.CRUser = UserInfo.User.UserName;
            new xy_actB().Insert(model);
            msg.Result = model;
        }

        /// <summary>
        /// 添加活动报名人员
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void ADDHDLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {

            xy_act_list model = new xy_act_list();
            model.name = context.Request["actname"] ?? "";
            model.tel = context.Request["acttel"] ?? "";
            model.act_id = int.Parse(context.Request["actid"] ?? "");
            model.num = context.Request["actnum"] ?? "";
            model.CRUser = UserInfo.User.UserName;
            model.CRDate = DateTime.Now;
            new xy_act_listB().Insert(model);
            msg.Result = model;
        }


        /// <summary>
        /// 获取活动信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void HDLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            msg.Result = new xy_actB().GetDTByCommand(" select * from xy_act  order by act_time desc ");//
            //msg.Result = new xy_jhB().GetEntities(d => d.ID != -1); ;
        }

        /// <summary>
        /// 获取活动报名人员信息
        /// </summary>
        /// <param name="context"></param>
        /// <param name="msg"></param>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="UserInfo"></param>
        public void HDRYLIST(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            msg.Result = new xy_act_listB().GetDTByCommand(" select * from xy_act_list where act_id=" + P1);//
        }




        public void GETJZXM(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            msg.Result = new xy_act_listB().GetDTByCommand(" select * from xy_jzxmlb");//
        }



        public void WXZF(HttpContext context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
        {
            string code = context.Request["code"] ?? "";
            string orderid = context.Request["orderid"] ?? "";
            WeiXinPay.WXPayJsapi(ref msg, UserInfo.User.UserName, orderid, code, context.Request.UserHostAddress);
        }
    }
}